package com.lsa.edmonds.chap1;

import java.util.List;

import com.lsa.helpers.Utils;
import com.lsa.shenn.common.Sorter;

public class BubbleSort implements Sorter
{
	public int[] sort(int[] array)
	{
		if (Utils.isEmpty(array))
			return array;
		
		boolean isElementsWasSwapped;
		
		do
		{
			isElementsWasSwapped = false;
		
			for(int i = 1; i < array.length; ++i)
			{
				if (array[i-1] > array[i])
				{
					Utils.swap(array, i-1, i);
					isElementsWasSwapped = true;
				}
			}
		}
		while(isElementsWasSwapped);
		
		return array;
	}

	public List<Integer> sort(List<Integer> array)
	{
		return null;
	}
}
